﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.ObjectModel;
namespace vxi.chat.library
{
    [Serializable]
    public class VxiChatSession
    {
        /// <summary>
        /// 会话的标识位，32位Int
        /// </summary>
        public static Int32 VXI_EVT_SESSION_ID;

        private Int32 sessionID;


        /// <summary>
        /// 会话中人数
        /// </summary>
        private int seesionMember;

        /// <summary>
        /// 会话启动时间
        /// </summary>
        private DateTime sessionBeginTime;

        /// <summary>
        /// 参与会话的客户端
        /// </summary>
        private ObservableCollection<VxiUserBase> userCollections;

        public ObservableCollection<VxiUserBase> UserCollections
        {
            get { return userCollections; }
            set { userCollections = value; }
        }

        public DateTime SessionBeginTime
        {
            get { return sessionBeginTime; }
        }

        public Int32 SessionID
        {
            get { return sessionID; }
            set { sessionID = value; }
        }

        public int SeesionMember
        {
            get { return seesionMember; }
        }

        public static int incSessionID()
        {
            VXI_EVT_SESSION_ID = VXI_EVT_SESSION_ID > 2147483647 ? 1 : (VXI_EVT_SESSION_ID + 1);
            return VXI_EVT_SESSION_ID;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public VxiChatSession()
        {
            sessionID = incSessionID();
            sessionBeginTime = DateTime.Now;
            seesionMember = 0;
            userCollections = new ObservableCollection<VxiUserBase>();
            userCollections.CollectionChanged += (s, e) =>
            {
                seesionMember = userCollections.Count();
            };
        }

    }


}
